
void setup(){
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  pinMode(6,INPUT);
  pinMode(11,INPUT);
  pinMode(12,INPUT);
  
}

void loop(){

    plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);

	  /*plen will be unequal to zero if there is a valid packet (without crc error) */
    if(plen!=0){
			// arp is broadcast if unknown but a host may also
      // verify the mac address by sending it to 
      // a unicast address.
      if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
      	es.ES_make_arp_answer_from_request(buf);
      }
      // check if ip packets (icmp or udp) are for us:
      if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)!=0){
         if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
         		// a ping packet, let's send pong
            es.ES_make_echo_reply_from_request(buf,plen);
   		    }
      }
    }  
}
